<extend name="Base:main" />
<block name="title">
<title>蔬菜外卖 - 设置配送运费</title>
</block>
<block name="main-content">
<div class="row">
	<div class="box col-md-12">
		<div class="box-inner">
			<div class="box-header well" data-original-title="">
				<h2>
					<i class="glyphicon glyphicon-user"></i>设置配送运费
				</h2>

				<div class="box-icon">
					<a href="#" class="btn btn-add btn-round btn-default"><i
						class="glyphicon glyphicon-plus"></i></a> <a href="#"
						class="btn btn-minimize btn-round btn-default"><i
						class="glyphicon glyphicon-chevron-up"></i></a> <a href="#"
						class="btn btn-close btn-round btn-default"><i
						class="glyphicon glyphicon-remove"></i></a>
				</div>
			</div>
			<div class="box-content">
				<div class="alert alert-info">对配送运费进行设置</div>
				<table
					class="table table-striped table-bordered bootstrap-datatable datatable responsive">
					<thead>
						<tr>
							<th>序号</th>
							<th>金额</th>
							<th>配送费用</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>1</td>
							<td>少于<label id="limit" name="limit">{$list.limit}</label>元
							</td>
							<td><label id="carriage" name="carriage">{$list.carriage}</label>元</td>
							<td>
								<button class="btn btn-primary btn-xs"
									onclick="edit({$list['id']});" data-toggle="modal">
									<i class="glyphicon glyphicon-edit icon-white"></i>
								</button>
							</td>
						</tr>

						<tr>
							<td>2</td>
							<td>介于{$list.limit}——<label id="slimit" name="slimit">{$list1.limit}</label>元
							</td>
							<td><label id="scarriage" name="scarriage">{$list1.carriage}</label>元</td>
							<td>
								<button class="btn btn-primary btn-xs"
									onclick="sedit({$list1['id']});" data-toggle="modal">
									<i class="glyphicon glyphicon-edit icon-white"></i>
								</button>
							</td>
						</tr>
					</tbody>
				</table>
				<!-- end box-content -->
			</div>
			<!-- end box-inner -->
		</div>
		<!-- end box -->
	</div>
	<!-- end row -->
	<!-- 删除菜单弹出框 -->
	<!-- 编辑菜单弹出框 -->
	<div class="modal fade" id="myEditModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width: 900px;">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">修改配送费用</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal style-form" method="get">
						<div class="form-group">
							<label class="col-sm-2 col-sm-2 control-label">少于：</label>
							<div class="col-sm-3">
								<input class="form-control" name="elimit" id="elimit" />
							</div>
							<label class="col-sm-1 col-sm-1 control-label">元</label> <label
								class="col-sm-2 col-sm-2 control-label">配送费用：</label>
							<div class="col-sm-3">
								<input class="form-control" name="ecarriage" id="ecarriage" />
							</div>
							<label class="col-sm-1 col-sm-1 control-label">元</label>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="button" class="btn btn-danger">确定</button>
				</div>
			</div>
		</div>
	</div>

	<!-- 编辑菜单弹出框 -->
	<div class="modal fade" id="mySEditModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width: 900px;">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">修改配送费用</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal style-form" method="get">
						<div class="form-group">
							<label class="col-sm-2 col-sm-2 control-label">介于：</label> <label
								class="col-sm-1 col-sm-1 control-label" id="ylimit"
								name="ylimit"></label>
							<div class="col-sm-2">
								<input class="form-control" name="selimit" id="selimit" />
							</div>
							<label class="col-sm-1 col-sm-1 control-label">元</label> <label
								class="col-sm-2 col-sm-2 control-label">配送费用：</label>
							<div class="col-sm-3">
								<input class="form-control" name="secarriage" id="secarriage" />
							</div>
							<label class="col-sm-1 col-sm-1 control-label">元</label>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="button" class="btn btn-danger">确定</button>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="js-content"> <script
	src="__PUBLIC__/assets/js/jquery-ui-1.9.2.custom.min.js"></script> <script
	src="__PUBLIC__/assets/js/jquery.tagsinput.js"></script> <script
	type="text/javascript" src="__PUBLIC__/js/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ajaxfileupload.js"></script>
<script type="text/javascript"
	src="__PUBLIC__/assets/js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
</body>
<script type="text/javascript">

  var editurl="__APP__/Admin/Order/editCarriage";
  //打开编辑的modal.
  function  edit(i)
  {
  	var id=i;
  	$(".btn-danger").attr('id',id);
    var limit = $("#limit").text();
    var carriage = $("#carriage").text();
  	$("#elimit").val(limit);
    $("#ecarriage").val(carriage);
  	$("#myEditModal").modal('show');
  }
    function  sedit(i)
  {
    var id=i;
    $(".btn-danger").attr('id',id);
    var limit = $("#slimit").text();
    var ylimit = $("#limit").text();
    var carriage = $("#scarriage").text();
    $("#ylimit").text(ylimit+"——");
    $("#selimit").val(limit);
    $("#secarriage").val(carriage);
    $("#mySEditModal").modal('show');
  }
//编辑框关闭时候的操作. 
  $("#myEditModal").on("hidden.bs.modal", function() {
		$(this).removeData("bs.modal");
	});
//编辑操作.
	$('#myEditModal').on('click','button.btn-danger',function (a){
				var id=$(this).attr("id");
		  		var limit=$("#elimit").val();
		  		var carriage=$("#ecarriage").val();
          $.post(editurl,{id:id,limit:limit,carriage:carriage},
            function(data){
              if(data.res=='1'){
                alert("修改成功！");
                setTimeout(function(){window.location.reload();},1000);
               }else{
                  alert("修改失败！");
                  setTimeout(function(){window.location.reload();},1000);
                } 
              },
              'json'
          );
		  	});


  //编辑操作.
  $('#mySEditModal').on('click','button.btn-danger',function (a){
        var id=$(this).attr("id");
          var limit=$("#selimit").val();
          var carriage=$("#secarriage").val();
          $.post(editurl,{id:id,limit:limit,carriage:carriage},
            function(data){
              if(data.res=='1'){
                alert("修改成功！");
                setTimeout(function(){window.location.reload();},1000);
               }else{
                  alert("修改失败！");
                  setTimeout(function(){window.location.reload();},1000);
                } 
              },
              'json'
          );
        });
  </script> </block>
